<template>
	<view class="body">
		<scroll-view scroll-y="true" class="scroll">
			<view class="comlum_Y" v-if="list.length">
				<view v-for="(item,index) in list" :key="index" class="item">
					<view class="shop">
						<image :src="item.category_image" mode="aspectFill" class="logo"></image>
						<view class="name">
							{{item.shop_name}}
						</view>
					</view>
					<view class="time">
						{{item.cdkey_time}}
					</view>
					<view class="deatil">
						<image :src="item.image" mode="aspectFill" class="img"></image>
						<view class="left">
							<view class="name">
								{{item.title}}
							</view>
							<view class="type">
								{{item.form_str}}
							</view>
						</view>
						<view class="right">
							<view class="num">
								{{item.num_str}}
							</view>
							<view class="size">
								{{item.give_str}}
							</view>
						</view>
					</view>
					<view class="CDKEY">
						<view class="left">
							兑换码
						</view>
						<view>
							{{item.cdkey}}
						</view>
					</view>
				</view>
				<u-loadmore :status="status" />
			</view>
			<empty v-else :content="'兑换记录'"></empty>
		</scroll-view>
	</view>
</template>

<script>
	import{
		redeemMain
	} from '@/api/user.js'
	import empty from './components/empty.vue'
	export default {
		data() {
			return {
				status: 'loadmore', //当前状态
				list: [],
				query:{
					page:1
				},
			}
		},
		onLoad() {
			this.getRedeemMain()
		},
		methods: {
			getRedeemMain(){
				redeemMain(this.query).then(({data:res})=>{
					console.log('res',res);
					if(res.code == 1){
						if(res.code == 1){
							const list = []
							this.status = 'loading'
							if (this.query.page > res.data.all_page) {
								console.log('nomore');
								this.status = 'nomore'
								return false
							} else {
								console.log('more');
								this.status = 'more'
								this.list = this.list.concat(res.data.list)
							}
							
							console.log('list', this.list);
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #e9e9e9;
	}

	.body {
		display: flex;
		flex-direction: column;
		align-items: center;

		.scroll {
			height: 100vh;

			.comlum_Y {
				display: flex;
				flex-direction: column;
				align-items: center;
				padding-top: 24rpx;

				.item {
					margin-bottom: 24rpx;
					width: 702rpx;
					height: 358rpx;
					background: #ffffff;
					border-radius: 16rpx;
					padding: 24rpx;

					.shop {
						display: flex;
						flex-direction: row;
						align-items: center;
						margin-bottom: 12rpx;

						.logo {
							width: 114rpx;
							height: 36rpx;
							margin-right: 12rpx;
						}

						.name {
							font-size: 28rpx;
							font-family: PingFang SC, PingFang SC-Bold;
							font-weight: 700;
							text-align: left;
							color: #333333;
						}
					}

					.time {
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC-Medium;
						font-weight: 500;
						color: #999999;
						margin-bottom: 24rpx;
					}

					.deatil {
						display: flex;
						flex-direction: row;

						.img {
							width: 160rpx;
							height: 120rpx;
							margin-right: 20rpx;
						}

						.left {
							display: flex;
							flex-direction: column;
							flex: 1;

							.name {
								font-size: 32rpx;
								font-family: PingFang SC, PingFang SC-Bold;
								font-weight: 700;
								text-align: left;
								color: #333333;
								margin-bottom: 8rpx;
							}

							.type {
								font-size: 24rpx;
								font-family: PingFang SC, PingFang SC-Medium;
								font-weight: 500;
								text-align: left;
								color: #999999;
							}
						}

						.right {
							display: flex;
							flex-direction: column;

							.num {
								font-size: 32rpx;
								font-family: PingFang SC, PingFang SC-Bold;
								font-weight: 700;
								text-align: right;
								color: #73F0EA;
								margin-bottom: 8rpx;
							}

							.size {
								font-size: 24rpx;
								font-family: PingFang SC, PingFang SC-Regular;
								font-weight: 400;
								text-align: right;
								color: #666666;
							}
						}
					}

					.CDKEY {
						margin-top: 16rpx;
						width: 654rpx;
						height: 66rpx;
						background: #f6f6f6;
						border-radius: 16rpx;
						padding: 0 24rpx;
						display: flex;
						flex-direction: row;
						align-items: center;
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC-Medium;
						font-weight: 500;
						text-align: left;
						color: #666666;

						.left {
							flex: 1;
						}
					}
				}
			}
		}
	}
</style>